package com.tuanzi.loan.business.entity.system;

import com.tuanzi.loan.core.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author Ray 2017/09/21
 */
@Data
@Entity
@Table(name = "TB_LOAN_USER")
@EqualsAndHashCode(callSuper = true)
public class User extends BaseEntity {

    private static final long serialVersionUID = 3451625044131316087L;

    @Id
    @GeneratedValue(generator = "uuid2")
    @GenericGenerator(name = "uuid2", strategy = "org.hibernate.id.UUIDGenerator")
    private String id;

    @NotBlank
    @Length(max = 200)
    @Column(name = "NAME")
    private String name;

    @NotBlank
    @Length(max = 200)
    @Column(name = "ACCOUNT")
    private String account;

    @NotBlank
    @Length(max = 36)
    @Column(name = "PARTNER_ID")
    private String partnerId;

    @NotBlank
    @Length(max = 200)
    @Column(name = "PWD")
    private String pwd;

    @Email
    @Length(max = 200)
    @Column(name = "EMAIL")
    private String email;

    @Length(max = 20)
    @Column(name = "PHONE")
    private String phone;

    @NotNull
    @Range(min = 0, max = Integer.MAX_VALUE)
    @Column(name = "RETRY_TIMES")
    private Integer retryTimes;

    @Column(name = "LAST_LOGIN_TIME")
    private Date lastLoginTime;

    @NotNull
    @Column(name = "LOCKED")
    private Boolean locked;

}
